package org.example.bifunction;

import com.alibaba.fastjson.JSONObject;

import java.util.function.BiFunction;

public class Java8BiFunction3 {
    public static void main(String[] args) {
        GPS obj = factory("40.741895", "-73.989308",GPS::new);
        System.err.println(JSONObject.toJSONString(obj,true));
    }

    static <R extends GPS> R factory(String latitude, String longitude, BiFunction<String,String,R> func){
        return func.apply(latitude,longitude);
    }
}
class GPS{
    String latitude;
    String longitude;

    public GPS(String latitude, String longitude) {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    @Override
    public String toString() {
        return "GPS{" +
                "latitude='" + latitude + '\'' +
                ", longitude='" + longitude + '\'' +
                '}';
    }
}
